#ifndef TRACE_H
#define TRACE_H

#define NR_TRACES   500
struct t_rec {
    u64	cycles; /* local(and global too) cpu tsc */
    u32	event;	/* event id */
    unsigned long data[5]; /* event data items */
};
struct trace_logger {
    struct t_rec* buf;
    spinlock_t	lock;
     int ptr;
};
#define WATCHDOG_NS	5000000000
extern int init_trace_buf(int cpu);
extern void free_trace_buf(int cpu);
extern enum hrtimer_restart dump_traces(void*);
extern enum hrtimer_restart dump_cpu_trace(struct hrtimer*);
extern void trace(u32 event, unsigned long d0, unsigned long d1,
	unsigned long d2, unsigned long d3, unsigned long d4);

#define TRC_SCHED_VM_ADD    0
#define TRC_SCHED_SLEEP	    1
#define TRC_SCHED_WAKE	    2
#define TRC_SCHED_YIELD	    3
#define TRC_SCHED_SWITCH_INFPREV    4
#define TRC_SCHED_SWITCH_INFNEXT    5
#define TRC_SCHED_SWITCH    6

#define TRC_SCHED_TIMER	    7
#define TRC_SCHED_RELAYED_TIMER	8
#define TRC_VCPU_SCHEDULE   9
#define TRC_RUNQ_TICKLE		10
#define TRC_TASKLET_SCHEDULE	11
#define TRC_CSCHED_TICK		12
#define TRC_CSCHED_SLEEP	13
#define TRC_CSCHED_WAKE		14
#define TRC_INTERNAL_CSCHED_TICK    15
#define TRC_DO_PENDING		16
#define TRC_PSEUDO_CLI		17
#define TRC_PSEUDO_STI		18
#define TRC_LOAD_BALANCE	19
#define TRC_CSCHED_SCHEDULE	20
#define TRC_PSEUDO_INTR		21
#define TRC_PSEUDO_EOI		22
#define TRC_PSEUDO_OPEN_INTR	23
#define TRC_TIMER_FN		24
#define TRC_SEND_IPI		25
#define TRC_INJECT_PEND_IPI	26
#define TRC_PEND_INTR		27
#define TRC_RUNQ_SORT		28

#define TRACE_0D(e)  trace((e), 0, 0, 0, 0, 0)
#define TRACE_1D(e,d)  trace((e), (d), 0, 0, 0, 0)
#define TRACE_2D(e,d1,d2)  trace((e), (d1), (d2), 0, 0, 0)
#define TRACE_3D(e,d1,d2,d3)  trace((e), (d1), (d2), (d3), 0, 0)
#define TRACE_4D(e,d1,d2,d3,d4)  trace((e), (d1), (d2), (d3), (d4), 0)
#define TRACE_5D(e,d1,d2,d3,d4,d5)  trace((e), (d1), (d2), (d3), (d4), (d5))
#endif
